//============================================================================================
/**
 * @file	dendou_pc.c
 * @brief	殿堂入りパソコン画面
 * @author	taya GAME FREAK inc.	-> Hiroyuki Nakamura
 *
 * @date	2006.04.21				-> 2009.03.30
 */
//============================================================================================
#include "common.h"
#include "savedata/dendou_data.h"
#include "system/wipe.h"
#include "system/gra_tool.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/fontproc.h"
#include "system/cursor_move.h"
#include "field/pair_poke_info.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_dendou_pc.h"

#include "../../field/pair_poke_idx.h"
#include "../../data/mmodel/mmodel.naix"

#include "application/dendou_pc.h"
#include "dendou_pc_sound.h"
#include "dendou_pc.naix"


//============================================================================================
//	定数定義
//============================================================================================

// OBJ ID
enum {
	OBJID_POKEGRA1 = 0,
	OBJID_POKEGRA2,
	OBJID_POKEWALK01,
	OBJID_POKEWALK02,
	OBJID_POKEWALK03,
	OBJID_POKEWALK04,
	OBJID_POKEWALK05,
	OBJID_POKEWALK06,
	OBJID_POKEWALK11,
	OBJID_POKEWALK12,
	OBJID_POKEWALK13,
	OBJID_POKEWALK14,
	OBJID_POKEWALK15,
	OBJID_POKEWALK16,
	OBJID_CURSOR,
	OBJID_L_ARROW,
	OBJID_R_ARROW,
	OBJID_RET_BUTTON,
	OBJID_MAX,
};

// BMPWIN ID
enum {
	BMPWIN_NICKNAME = 0,
	BMPWIN_NAME,
	BMPWIN_OYA,
	BMPWIN_WAZA1,
	BMPWIN_WAZA2,
	BMPWIN_WAZA3,
	BMPWIN_WAZA4,
	BMPWIN_TITLE,

	BMPWIN_NICKNAME_S,
	BMPWIN_NAME_S,
	BMPWIN_OYA_S,
	BMPWIN_WAZA1_S,
	BMPWIN_WAZA2_S,
	BMPWIN_WAZA3_S,
	BMPWIN_WAZA4_S,
	BMPWIN_TITLE_S,

	BMPWIN_RET,
	BMPWIN_MAX,
};

// 殿堂入りＰＣ画面ワーク
typedef struct {
	const DENDOU_SAVEDATA * sv;	// 殿堂入りセーブデータ

	GF_BGL_INI * bgl;			// BGLデータ

	// BMPWIN
	GF_BGL_BMPWIN	win[BMPWIN_MAX];

	// メッセージ関連
	MSGDATA_MANAGER * mman;
	MSGDATA_MANAGER * mmons;
	MSGDATA_MANAGER * mwaza;
	WORDSET * wset;
	STRBUF * tmpbuf1;
	STRBUF * tmpbuf2;

	// OBJ関連
	CATS_SYS_PTR	csp;
	CATS_RES_PTR	crp;
	CATS_ACT_PTR	cap[OBJID_MAX];

	CURSOR_MOVE_WORK * cmwk;	// カーソル移動ワーク

	ARCHANDLE * ped;			// 高さなど

	DENDOU_POKEMON_DATA	pd;		// ポケモンデータ
	STRBUF * pd_name;			// 名前
	STRBUF * pd_oya;			// 親名
	u32	poke_max;				// 登録ポケモン数
	u32	taikai_num;				// 大会番号

	s32	page;					// ページ番号
	s32	page_max;				// ページ数

	int	btn_id;					// ボタンＩＤ
	int	btn_cnt;				// ボタンアニメカウンター

	u16	swap_pokegra;			// ポケグラ用スワップフラグ
	u16	swap_selpoke;			// 連れ歩き用スワップフラグ

	int	main_seq;				// メインシーケンス
	int	next_seq;				// 次のシーケンス

}DENDOU_PC_WORK;

#define	CLA_H_NONE	( CLACT_U_HEADER_DATA_NONE )	// セルアクターヘッダーデータなし

#define	CLACT_ID_COMMON		( 56512 )	// この画面で使用するセルアクターのID

#define	SUB_ACTOR_DISTANCE	( 512*FX32_ONE )		// サブ画面のOBJ表示Y座標オフセット

// キャラリソースID
enum {
	CHR_ID_POKEGRA1 = CLACT_ID_COMMON,
	CHR_ID_POKEGRA2,
	CHR_ID_POKEWALK01,
	CHR_ID_POKEWALK02,
	CHR_ID_POKEWALK03,
	CHR_ID_POKEWALK04,
	CHR_ID_POKEWALK05,
	CHR_ID_POKEWALK06,
	CHR_ID_POKEWALK11,
	CHR_ID_POKEWALK12,
	CHR_ID_POKEWALK13,
	CHR_ID_POKEWALK14,
	CHR_ID_POKEWALK15,
	CHR_ID_POKEWALK16,
	CHR_ID_ETC,
	CHR_ID_MAX = CHR_ID_ETC - CLACT_ID_COMMON + 1
};
// パレットリソースID
enum {
	PAL_ID_POKEGRA1 = CLACT_ID_COMMON,
	PAL_ID_POKEGRA2,
	PAL_ID_POKEWALK01,
	PAL_ID_POKEWALK02,
	PAL_ID_POKEWALK03,
	PAL_ID_POKEWALK04,
	PAL_ID_POKEWALK05,
	PAL_ID_POKEWALK06,
	PAL_ID_POKEWALK11,
	PAL_ID_POKEWALK12,
	PAL_ID_POKEWALK13,
	PAL_ID_POKEWALK14,
	PAL_ID_POKEWALK15,
	PAL_ID_POKEWALK16,
	PAL_ID_ETC,
	PAL_ID_MAX = PAL_ID_ETC - CLACT_ID_COMMON + 1
};
// セルリソースID
enum {
	CEL_ID_POKEGRA1 = CLACT_ID_COMMON,
	CEL_ID_POKEWALK1,
	CEL_ID_POKEWALK2,
	CEL_ID_ETC,
	CEL_ID_MAX = CEL_ID_ETC - CLACT_ID_COMMON + 1
};
// セルアニメリソースID
enum {
	ANM_ID_POKEGRA1 = CLACT_ID_COMMON,
	ANM_ID_POKEWALK1,
	ANM_ID_POKEWALK2,
	ANM_ID_ETC,
	ANM_ID_MAX = ANM_ID_ETC - CLACT_ID_COMMON + 1
};

#define TEMP_STRBUF_SIZE	( 256 )			// テンポラリメッセージサイズ
#define	POKE_STRBUF_SIZE	( 256 )			// テンポラリポケモンデータ文字列サイズ

#define	POKEGRA_TEX_SIZE	( 0x20 * 100 )	// ポケモン一枚絵データ：テクスチャサイズ
#define	POKEGRA_PAL_SIZE	( 0x20 )		// ポケモン一枚絵データ：パレットサイズ
#define	POKEWALK_PAL_SIZE	( 0x20 )		// 連れ歩きポケモンのパレットサイズ

// 連れ歩きＯＢＪ表示座標
#define	POKE1_OBJ_PX	( 56 )
#define	POKE1_OBJ_PY	( 72 )
#define	POKE2_OBJ_PX	( 128 )
#define	POKE2_OBJ_PY	( 72 )
#define	POKE3_OBJ_PX	( 200 )
#define	POKE3_OBJ_PY	( 72 )
#define	POKE4_OBJ_PX	( 56 )
#define	POKE4_OBJ_PY	( 136 )
#define	POKE5_OBJ_PX	( 128 )
#define	POKE5_OBJ_PY	( 136 )
#define	POKE6_OBJ_PX	( 200 )
#define	POKE6_OBJ_PY	( 136 )

// ポケグラ表示座標
#define	POKEGRA_OBJ_PX	( 64 )
#define	POKEGRA_OBJ_PY	( 64 )

// BMPWINデータ
// ニックネーム
#define	BMPWIN_NICKNAME_PX		( 18 )
#define	BMPWIN_NICKNAME_PY		( 2 )
#define	BMPWIN_NICKNAME_SX		( 14 )
#define	BMPWIN_NICKNAME_SY		( 2 )
#define	BMPWIN_NICKNAME_PAL		( 15 )
#define	BMPWIN_NICKNAME_CGX		( 1 )
#define	BMPWIN_NICKNAME_S_CGX	( BMPWIN_NICKNAME_CGX + BMPWIN_NICKNAME_SX * BMPWIN_NICKNAME_SY )
// 種族名・レベル
#define	BMPWIN_NAME_PX			( 18 )
#define	BMPWIN_NAME_PY			( 7 )
#define	BMPWIN_NAME_SX			( 14 )
#define	BMPWIN_NAME_SY			( 4 )
#define	BMPWIN_NAME_PAL			( 15 )
#define	BMPWIN_NAME_CGX			( BMPWIN_NICKNAME_S_CGX + BMPWIN_NICKNAME_SX * BMPWIN_NICKNAME_SY )
#define	BMPWIN_NAME_S_CGX		( BMPWIN_NAME_CGX + BMPWIN_NAME_SX * BMPWIN_NAME_SY )
// 親名
#define	BMPWIN_OYA_PX			( 18 )
#define	BMPWIN_OYA_PY			( 14 )
#define	BMPWIN_OYA_SX			( 14 )
#define	BMPWIN_OYA_SY			( 2 )
#define	BMPWIN_OYA_PAL			( 15 )
#define	BMPWIN_OYA_CGX			( BMPWIN_NAME_S_CGX + BMPWIN_NAME_SX * BMPWIN_NAME_SY )
#define	BMPWIN_OYA_S_CGX		( BMPWIN_OYA_CGX + BMPWIN_OYA_SX * BMPWIN_OYA_SY )
// 技名
#define	BMPWIN_WAZA_SX			( 14 )
#define	BMPWIN_WAZA_SY			( 2 )
#define	BMPWIN_WAZA_PAL			( 15 )
#define	BMPWIN_WAZA_LPX			( 1 )
#define	BMPWIN_WAZA_RPX			( 17 )
#define	BMPWIN_WAZA_UPY			( 18 )
#define	BMPWIN_WAZA_DPY			( 21 )
#define	BMPWIN_WAZA1_CGX		( BMPWIN_OYA_S_CGX + BMPWIN_OYA_SX * BMPWIN_OYA_SY )
#define	BMPWIN_WAZA1_S_CGX		( BMPWIN_WAZA1_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA2_CGX		( BMPWIN_WAZA1_S_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA2_S_CGX		( BMPWIN_WAZA2_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA3_CGX		( BMPWIN_WAZA2_S_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA3_S_CGX		( BMPWIN_WAZA3_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA4_CGX		( BMPWIN_WAZA3_S_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
#define	BMPWIN_WAZA4_S_CGX		( BMPWIN_WAZA4_CGX + BMPWIN_WAZA_SX * BMPWIN_WAZA_SY )
// タイトル
#define	BMPWIN_TITLE_PX			( 1 )
#define	BMPWIN_TITLE_PY			( 0 )
#define	BMPWIN_TITLE_SX			( 30 )
#define	BMPWIN_TITLE_SY			( 2 )
#define	BMPWIN_TITLE_PAL		( 15 )
#define	BMPWIN_TITLE_CGX		( 1 )
#define	BMPWIN_TITLE_S_CGX		( BMPWIN_TITLE_CGX + BMPWIN_TITLE_SX * BMPWIN_TITLE_SY )
// 戻る
#define	BMPWIN_RET_PX			( 25 )
#define	BMPWIN_RET_PY			( 21 )
#define	BMPWIN_RET_SX			( 6 )
#define	BMPWIN_RET_SY			( 2 )
#define	BMPWIN_RET_PAL			( 15 )
#define	BMPWIN_RET_CGX			( BMPWIN_TITLE_S_CGX + BMPWIN_TITLE_SX * BMPWIN_TITLE_SY )

// フォントカラー
#define	FCOL_WN15			( GF_PRINTCOLOR_MAKE( 15, 2, 0 ) )
#define	FCOL_BN15_TOUCH		( GF_PRINTCOLOR_MAKE( 15, 1, 0 ) )

#define	STR_SEX_PX	( 8 )	// 性別表示Ｘ座標補正値


//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static void VBlankFunc( void * work );
static void VramInit(void);
static void BgInit( DENDOU_PC_WORK * wk );
static void BgExit( DENDOU_PC_WORK * wk );
static void ObjInit( DENDOU_PC_WORK * wk );
static void ObjExit( DENDOU_PC_WORK * wk );
static void ObjMain( DENDOU_PC_WORK * wk );
static void MsgInit( DENDOU_PC_WORK * wk );
static void MsgExit( DENDOU_PC_WORK * wk );
static void BmpInit( DENDOU_PC_WORK * wk );
static void BmpExit( DENDOU_PC_WORK * wk );
static void FadeInSet(void);
static void FadeOutSet(void);
static void CursorInit( DENDOU_PC_WORK * wk );
static void CursorExit( DENDOU_PC_WORK * wk );
static void CursorMoveCallBack_On( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Off( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Touch( void * work, int now_pos, int old_pos );
static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos );

static BOOL MainFunc( DENDOU_PC_WORK * wk );

static void PageChangeInit( DENDOU_PC_WORK * wk );
static void PageChange( DENDOU_PC_WORK * wk, s8 mv );
static void PokeChange( DENDOU_PC_WORK * wk, u32 pos );
static void PokeInfoOff( DENDOU_PC_WORK * wk );
static BOOL ButtonAnime( DENDOU_PC_WORK * wk );
static void CursorMove( DENDOU_PC_WORK * wk, u32 pos );
static void SelPokeObjChange( DENDOU_PC_WORK * wk, u32 id, u32 pos, u32 chr_res, u32 pal_res );
static int GetMonsArcIdx(const int inMonsNo, const u16 inFormNo, const int inSex);


//============================================================================================
//	グローバル変数
//============================================================================================

// VRAM割り振り
static const GF_BGL_DISPVRAM VramTbl = {
	GX_VRAM_BG_128_B,				// メイン2DエンジンのBG
	GX_VRAM_BGEXTPLTT_NONE,			// メイン2DエンジンのBG拡張パレット

	GX_VRAM_SUB_BG_128_C,			// サブ2DエンジンのBG
	GX_VRAM_SUB_BGEXTPLTT_NONE,		// サブ2DエンジンのBG拡張パレット

	GX_VRAM_OBJ_64_E,				// メイン2DエンジンのOBJ
	GX_VRAM_OBJEXTPLTT_NONE,		// メイン2DエンジンのOBJ拡張パレット

	GX_VRAM_SUB_OBJ_16_I,			// サブ2DエンジンのOBJ
	GX_VRAM_SUB_OBJEXTPLTT_NONE,	// サブ2DエンジンのOBJ拡張パレット

	GX_VRAM_TEX_0_A,				// テクスチャイメージスロット
	GX_VRAM_TEXPLTT_01_FG			// テクスチャパレットスロット
};

// カーソル移動データ
// タッチ座標
static const RECT_HIT_TBL RectHitTbl[] =
{
	{ TP_USE_CIRCLE,  56,  64, 32 },	// 00: ポケモン１
	{ TP_USE_CIRCLE, 128,  64, 32 },	// 01: ポケモン２
	{ TP_USE_CIRCLE, 200,  64, 32 },	// 02: ポケモン３
	{ TP_USE_CIRCLE,  56, 128, 32 },	// 03: ポケモン４
	{ TP_USE_CIRCLE, 128, 128, 32 },	// 04: ポケモン５
	{ TP_USE_CIRCLE, 200, 128, 32 },	// 05: ポケモン６

	{ 160, 191, 192, 255 },		// 06: もどる

	{ RECT_HIT_END, 0, 0, 0 }
};
// 移動データ
static const POINTER_WORK KeyMoveTbl[] =
{
	{ POKE1_OBJ_PX, POKE1_OBJ_PY, 0, 0,	0, 3, 0, 1 },	// 00: ポケモン１
	{ POKE2_OBJ_PX, POKE2_OBJ_PY, 0, 0,	1, 4, 0, 2 },	// 01: ポケモン２
	{ POKE3_OBJ_PX, POKE3_OBJ_PY, 0, 0,	2, 5, 1, 2 },	// 02: ポケモン３
	{ POKE4_OBJ_PX, POKE4_OBJ_PY, 0, 0,	0, 6, 3, 4 },	// 03: ポケモン４
	{ POKE5_OBJ_PX, POKE5_OBJ_PY, 0, 0,	1, 6, 3, 5 },	// 04: ポケモン５
	{ POKE6_OBJ_PX, POKE6_OBJ_PY, 0, 0,	2, 6, 4, 5 },	// 05: ポケモン６

	{ 224, 176, 0, 0,	CURSORMOVE_RETBIT|5, 6, 6, 6 },	// 06: もどる
};
// コールバック関数
static const CURSORMOVE_CALLBACK CursorMoveCallBack = {
	CursorMoveCallBack_On,
	CursorMoveCallBack_Off,
	CursorMoveCallBack_Move,
	CursorMoveCallBack_Touch
};

// 矢印タッチ座標
static const RECT_HIT_TBL ArrowRectHitTbl[] =
{
	{ 88, 119,   0,  23 },		// 00: 左矢印
	{ 88, 119, 232, 255 },		// 01: 右矢印
	{ RECT_HIT_END, 0, 0, 0 }
};

// 連れ歩きＯＢＪ表示座標テーブル
static const s16 SelPokePosTbl[][2] =
{	// x, y
	{ POKE1_OBJ_PX, POKE1_OBJ_PY },
	{ POKE2_OBJ_PX, POKE2_OBJ_PY },
	{ POKE3_OBJ_PX, POKE3_OBJ_PY },
	{ POKE4_OBJ_PX, POKE4_OBJ_PY },
	{ POKE5_OBJ_PX, POKE5_OBJ_PY },
	{ POKE6_OBJ_PX, POKE6_OBJ_PY },
};

// ＯＢＪデータ
static const TCATS_OBJECT_ADD_PARAM_S ClaPrm[] =
{
	{	// 上画面ポケモン１
		64, 64, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DSUB,
		{ CHR_ID_POKEGRA1, PAL_ID_POKEGRA1, CEL_ID_POKEGRA1, ANM_ID_POKEGRA1, CLA_H_NONE, CLA_H_NONE },
		1, 0
	},
	{	// 上画面ポケモン２（スワップ用）
		64, 64, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DSUB,
		{ CHR_ID_POKEGRA2, PAL_ID_POKEGRA2, CEL_ID_POKEGRA1, ANM_ID_POKEGRA1, CLA_H_NONE, CLA_H_NONE },
		1, 0
	},
	{	// 下画面ポケモン１
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK01, PAL_ID_POKEWALK01, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン２
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK02, PAL_ID_POKEWALK02, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン３
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK03, PAL_ID_POKEWALK03, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン４
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK04, PAL_ID_POKEWALK04, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン５
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK05, PAL_ID_POKEWALK05, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン６
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK06, PAL_ID_POKEWALK06, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン１（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK11, PAL_ID_POKEWALK11, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン２（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK12, PAL_ID_POKEWALK12, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン３（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK13, PAL_ID_POKEWALK13, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン４（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK14, PAL_ID_POKEWALK14, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン５（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK15, PAL_ID_POKEWALK15, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// 下画面ポケモン６（スワップ用）
		512, 480, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_POKEWALK16, PAL_ID_POKEWALK16, CEL_ID_POKEWALK1, ANM_ID_POKEWALK1, CLA_H_NONE, CLA_H_NONE },
		2, 0
	},
	{	// カーソル
		POKE1_OBJ_PX, POKE1_OBJ_PY, 0,
		3, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_ETC, PAL_ID_ETC, CEL_ID_ETC, ANM_ID_ETC, CLA_H_NONE, CLA_H_NONE },
		0, 0
	},
	{	// 左矢印
		12, 104, 0,
		0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_ETC, PAL_ID_ETC, CEL_ID_ETC, ANM_ID_ETC, CLA_H_NONE, CLA_H_NONE },
		1, 0
	},
	{	// 右矢印
		244, 104, 0,
		1, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_ETC, PAL_ID_ETC, CEL_ID_ETC, ANM_ID_ETC, CLA_H_NONE, CLA_H_NONE },
		1, 0
	},
	{	// 戻るボタン
		224, 176, 0,
		2, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
		{ CHR_ID_ETC, PAL_ID_ETC, CEL_ID_ETC, ANM_ID_ETC, CLA_H_NONE, CLA_H_NONE },
		1, 0
	},
};

// 連れ歩きＯＢＪ空データ
static const TCATS_OBJECT_ADD_PARAM_S SelPokeParam = {
	0, 0, 0,
	0, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
	{ CLA_H_NONE, CLA_H_NONE, CLA_H_NONE, CLA_H_NONE, CLA_H_NONE, CLA_H_NONE },
	1, 0
};

// BMPWINデータ
static const BMPWIN_DAT BmpWinData[] =
{
	{	// ニックネーム
		GF_BGL_FRAME0_S, BMPWIN_NICKNAME_PX, BMPWIN_NICKNAME_PY,
		BMPWIN_NICKNAME_SX, BMPWIN_NICKNAME_SY, BMPWIN_NICKNAME_PAL, BMPWIN_NICKNAME_CGX
	},
	{	// 種族名・レベル
		GF_BGL_FRAME0_S, BMPWIN_NAME_PX, BMPWIN_NAME_PY,
		BMPWIN_NAME_SX, BMPWIN_NAME_SY, BMPWIN_NAME_PAL, BMPWIN_NAME_CGX
	},
	{	// 親名
		GF_BGL_FRAME0_S, BMPWIN_OYA_PX, BMPWIN_OYA_PY,
		BMPWIN_OYA_SX, BMPWIN_OYA_SY, BMPWIN_OYA_PAL, BMPWIN_OYA_CGX
	},
	{	// 技名１
		GF_BGL_FRAME0_S, BMPWIN_WAZA_LPX, BMPWIN_WAZA_UPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA1_CGX
	},
	{	// 技名２
		GF_BGL_FRAME0_S, BMPWIN_WAZA_RPX, BMPWIN_WAZA_UPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA2_CGX
	},
	{	// 技名３
		GF_BGL_FRAME0_S, BMPWIN_WAZA_LPX, BMPWIN_WAZA_DPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA3_CGX
	},
	{	// 技名４
		GF_BGL_FRAME0_S, BMPWIN_WAZA_RPX, BMPWIN_WAZA_DPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA4_CGX
	},
	{	// タイトル
		GF_BGL_FRAME0_M, BMPWIN_TITLE_PX, BMPWIN_TITLE_PY,
		BMPWIN_TITLE_SX, BMPWIN_TITLE_SY, BMPWIN_TITLE_PAL, BMPWIN_TITLE_CGX
	},

	{	// ニックネーム（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_NICKNAME_PX, BMPWIN_NICKNAME_PY,
		BMPWIN_NICKNAME_SX, BMPWIN_NICKNAME_SY, BMPWIN_NICKNAME_PAL, BMPWIN_NICKNAME_S_CGX
	},
	{	// 種族名・レベル（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_NAME_PX, BMPWIN_NAME_PY,
		BMPWIN_NAME_SX, BMPWIN_NAME_SY, BMPWIN_NAME_PAL, BMPWIN_NAME_S_CGX
	},
	{	// 親名（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_OYA_PX, BMPWIN_OYA_PY,
		BMPWIN_OYA_SX, BMPWIN_OYA_SY, BMPWIN_OYA_PAL, BMPWIN_OYA_S_CGX
	},
	{	// 技名１（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_WAZA_LPX, BMPWIN_WAZA_UPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA1_S_CGX
	},
	{	// 技名２（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_WAZA_RPX, BMPWIN_WAZA_UPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA2_S_CGX
	},
	{	// 技名３（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_WAZA_LPX, BMPWIN_WAZA_DPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA3_S_CGX
	},
	{	// 技名４（スワップ用）
		GF_BGL_FRAME0_S, BMPWIN_WAZA_RPX, BMPWIN_WAZA_DPY,
		BMPWIN_WAZA_SX, BMPWIN_WAZA_SY, BMPWIN_WAZA_PAL, BMPWIN_WAZA4_S_CGX
	},
	{	// タイトル（スワップ用）
		GF_BGL_FRAME0_M, BMPWIN_TITLE_PX, BMPWIN_TITLE_PY,
		BMPWIN_TITLE_SX, BMPWIN_TITLE_SY, BMPWIN_TITLE_PAL, BMPWIN_TITLE_S_CGX
	},

	{	// 戻る
		GF_BGL_FRAME0_M, BMPWIN_RET_PX, BMPWIN_RET_PY,
		BMPWIN_RET_SX, BMPWIN_RET_SY, BMPWIN_RET_PAL, BMPWIN_RET_CGX
	},
};


//--------------------------------------------------------------------------------------------
/**
 * PROC初期化
 *
 * @param   proc
 * @param   seq
 *
 * @retval  PROC_RESULT
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT DendouPc_PROC_Init( PROC * proc, int * seq )
{
	DENDOU_PC_WORK * wk;

	// 割り込み停止
	sys_VBlankFuncChange( NULL, NULL );
	sys_HBlankIntrStop();
	// 表示初期化
	GF_Disp_GX_VisibleControlDirect( 0 );
	GF_Disp_GXS_VisibleControlDirect( 0 );
	// ブレンド初期化
	G2_BlendNone();
	G2S_BlendNone();
	// タッチパネルシステム初期化
	InitTPSystem();
	InitTPNoBuff( 4 );
	// サブ画面をメインに
	GX_SetDispSelect( GX_DISP_SELECT_SUB_MAIN );

	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_DENDOU_PC, 0x40000 );
	wk = PROC_AllocWork( proc, sizeof(DENDOU_PC_WORK), HEAPID_DENDOU_PC );
	MI_CpuClear8( wk, sizeof(DENDOU_PC_WORK) );

	wk->sv = PROC_GetParentWork( proc );
	wk->page_max = DendouData_GetRecordCount( wk->sv );
	wk->ped = ArchiveDataHandleOpen( ARC_PM_EDIT, HEAPID_DENDOU_PC );

	VramInit();
	BgInit( wk );
	ObjInit( wk );

	MsgInit( wk );
	BmpInit( wk );

	CursorInit( wk );

	PageChange( wk, 0 );

	sys_VBlankFuncChange( VBlankFunc, wk );

	return PROC_RES_FINISH;
}

//--------------------------------------------------------------------------------------------
/**
 * PROC終了
 *
 * @param   proc
 * @param   seq
 *
 * @retval  PROC_RESULT
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT DendouPc_PROC_Quit( PROC * proc, int * seq )
{
	DENDOU_PC_WORK * wk = PROC_GetWork( proc );

	sys_VBlankFuncChange( NULL, wk );

	CursorExit( wk );
	BmpExit( wk );
	MsgExit( wk );

	ObjExit( wk );
	BgExit( wk );

	ArchiveDataHandleClose( wk->ped );

	//BTS4835対応
	StopTP();

	PROC_FreeWork( proc );
	sys_DeleteHeap( HEAPID_DENDOU_PC );

	return PROC_RES_FINISH;
}

//--------------------------------------------------------------------------------------------
/**
 * PROCメイン
 *
 * @param   proc
 * @param   seq
 *
 * @retval  PROC_RESULT
 */
//--------------------------------------------------------------------------------------------
PROC_RESULT DendouPc_PROC_Main( PROC * proc, int * seq )
{
	DENDOU_PC_WORK * wk = PROC_GetWork( proc );

	switch( *seq ){
	case 0:		// フェード設定
		FadeInSet();
//		Snd_SePlay( SE_DENDOUPC_LOGIN );
		*seq += 1;
		break;

	case 1:		// フェードイン
		if( WIPE_SYS_EndCheck() == TRUE ){
			*seq += 1;
		}
		break;

	case 2:		// メイン
		if( MainFunc( wk ) == FALSE ){
			*seq += 1;
		}
		break;

	case 3:		// 終了
		if( WIPE_SYS_EndCheck() == TRUE ){
			return PROC_RES_FINISH;
		}
	}

	ObjMain( wk );
	CATS_Draw( wk->crp );

	return PROC_RES_CONTINUE;
}

//--------------------------------------------------------------------------------------------
/**
 * VBLANK関数
 *
 * @param   work	殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void VBlankFunc( void * work )
{
	DENDOU_PC_WORK * wk = work;

	GF_BGL_VBlankFunc( wk->bgl );

	CATS_RenderOamTrans();

	OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ転送（メイン画面）
 *
 * @param   buf		転送データ
 * @param	adrs	転送位置
 * @param	siz		転送サイズ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjVramTrans( void * buf, u32 adrs, u32 siz )
{
	DC_FlushRange( buf, siz );
	GX_LoadOBJ( buf, adrs, siz );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ転送（サブ画面）
 *
 * @param   buf		転送データ
 * @param	adrs	転送位置
 * @param	siz		転送サイズ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjVramTransSub( void * buf, u32 adrs, u32 siz )
{
	DC_FlushRange( buf, siz );
	GXS_LoadOBJ( buf, adrs, siz );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJパレット転送（メイン画面）
 *
 * @param   buf		転送データ
 * @param	adrs	転送位置
 * @param	siz		転送サイズ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjPlttVramTrans( void * buf, u32 adrs, u32 siz )
{
	DC_FlushRange( buf, siz );
	GX_LoadOBJPltt( buf, adrs, siz );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJパレット転送（サブ画面）
 *
 * @param   buf		転送データ
 * @param	adrs	転送位置
 * @param	siz		転送サイズ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjPlttVramTransSub( void * buf, u32 adrs, u32 siz )
{
	DC_FlushRange( buf, siz );
	GX_LoadOBJPltt( buf, adrs, siz );
}

//--------------------------------------------------------------------------------------------
/**
 * VRAM初期化
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void VramInit(void)
{
	GF_Disp_SetBank( &VramTbl );
}

//--------------------------------------------------------------------------------------------
/**
 * BG初期化
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgInit( DENDOU_PC_WORK * wk )
{
	wk->bgl = GF_BGL_BglIniAlloc( HEAPID_DENDOU_PC );

	{	// BG SYSTEM
		GF_BGL_SYS_HEADER sysh = {
			GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BGMODE_0, GX_BG0_AS_2D,
		};
		GF_BGL_InitBG( &sysh );
	}

	{	// メイン画面：文字
		GF_BGL_BGCNT_HEADER cnth= {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
			0, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( wk->bgl, GF_BGL_FRAME0_M, &cnth, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( wk->bgl, GF_BGL_FRAME0_M );
		GF_BGL_ClearCharSet( GF_BGL_FRAME0_M, 0x20, 0, HEAPID_DENDOU_PC );
	}
	{	// メイン画面：背景
		GF_BGL_BGCNT_HEADER cnth= {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf000, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			1, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( wk->bgl, GF_BGL_FRAME1_M, &cnth, GF_BGL_MODE_TEXT );
	}

	{	// サブ画面：文字
		GF_BGL_BGCNT_HEADER cnth= {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
			0, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( wk->bgl, GF_BGL_FRAME0_S, &cnth, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( wk->bgl, GF_BGL_FRAME0_S );
		GF_BGL_ClearCharSet( GF_BGL_FRAME0_S, 0x20, 0, HEAPID_DENDOU_PC );
	}
	{	// サブ画面：背景
		GF_BGL_BGCNT_HEADER cnth= {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf000, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			1, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( wk->bgl, GF_BGL_FRAME1_S, &cnth, GF_BGL_MODE_TEXT );
	}


	{	// グラフィックロード
		ARCHANDLE * ah = ArchiveDataHandleOpen( ARC_DENDOU_PC_GRA, HEAPID_DENDOU_PC );

		ArcUtil_HDL_ScrnSet(
			ah, NARC_dendou_pc_m_bg_lz_NSCR,
			wk->bgl, GF_BGL_FRAME1_M, 0, 0, TRUE, HEAPID_DENDOU_PC );
		ArcUtil_HDL_BgCharSet(
			ah, NARC_dendou_pc_m_bg_lz_NCGR,
			wk->bgl, GF_BGL_FRAME1_M, 0, 0, TRUE, HEAPID_DENDOU_PC );
		ArcUtil_HDL_PalSet(
			ah, NARC_dendou_pc_m_bg_NCLR, PALTYPE_MAIN_BG, 0, 0x20, HEAPID_DENDOU_PC );

		ArcUtil_HDL_ScrnSet(
			ah, NARC_dendou_pc_s_bg_lz_NSCR,
			wk->bgl, GF_BGL_FRAME1_S, 0, 0, TRUE, HEAPID_DENDOU_PC );
		ArcUtil_HDL_BgCharSet(
			ah, NARC_dendou_pc_s_bg_lz_NCGR,
			wk->bgl, GF_BGL_FRAME1_S, 0, 0, TRUE, HEAPID_DENDOU_PC );
		ArcUtil_HDL_PalSet(
			ah, NARC_dendou_pc_s_bg_NCLR, PALTYPE_SUB_BG, 0, 0x20, HEAPID_DENDOU_PC );

		ArchiveDataHandleClose( ah );
	}

	// フォントパレット
	SystemFontPaletteLoad( PALTYPE_MAIN_BG, 15 * 32, HEAPID_DENDOU_PC );
	SystemFontPaletteLoad( PALTYPE_SUB_BG, 15 * 32, HEAPID_DENDOU_PC );
}

//--------------------------------------------------------------------------------------------
/**
 * BG削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgExit( DENDOU_PC_WORK * wk )
{
	GF_BGL_BGControlExit( wk->bgl, GF_BGL_FRAME1_S );
	GF_BGL_BGControlExit( wk->bgl, GF_BGL_FRAME0_S );
	GF_BGL_BGControlExit( wk->bgl, GF_BGL_FRAME1_M );
	GF_BGL_BGControlExit( wk->bgl, GF_BGL_FRAME0_M );
	sys_FreeMemoryEz( wk->bgl );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ初期化
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjInit( DENDOU_PC_WORK * wk )
{
	u32	i;

	wk->csp = CATS_AllocMemory( HEAPID_DENDOU_PC );
	wk->crp = CATS_ResourceCreate( wk->csp );

	{
		TCATS_OAM_INIT	coi = {
			0, 128,
			0, 32,
			0, 128,
			0, 32,
		};
		TCATS_CHAR_MANAGER_MAKE ccmm = {
			1024,
			1024*64,
			1024*16,
			GX_OBJVRAMMODE_CHAR_1D_64K,
			GX_OBJVRAMMODE_CHAR_1D_64K
		};
		CATS_SystemInit( wk->csp, &coi, &ccmm, 32 );
	}
	{
		TCATS_RESOURCE_NUM_LIST	crnl = {
			CHR_ID_MAX, PAL_ID_MAX, CEL_ID_MAX, ANM_ID_MAX, 0, 0
		};
		CATS_ClactSetInit( wk->csp, wk->crp, OBJID_MAX );
		CATS_ResourceManagerInit( wk->csp, wk->crp, &crnl );
	}
	{
		CLACT_U_EASYRENDER_DATA * renddata = CATS_EasyRenderGet( wk->csp );
		CLACT_U_SetSubSurfaceMatrix( renddata, 0, SUB_ACTOR_DISTANCE );
	}

	// リソース読み込み
	{	// 上画面ポケモン
		ARCHANDLE * ah = ArchiveDataHandleOpen( ARC_BATT_OBJ, HEAPID_DENDOU_PC );

		CATS_LoadResourceCharArcH(
			wk->csp, wk->crp, ah, POKE_OAM_NCGR, 0, NNS_G2D_VRAM_TYPE_2DSUB, CHR_ID_POKEGRA1 );
		CATS_LoadResourceCharArcH(
			wk->csp, wk->crp, ah, POKE_OAM_NCGR, 0, NNS_G2D_VRAM_TYPE_2DSUB, CHR_ID_POKEGRA2 );
		CATS_LoadResourcePlttArcH(
			wk->csp, wk->crp, ah, POKE_OAM_NCLR, 0, 1, NNS_G2D_VRAM_TYPE_2DSUB, PAL_ID_POKEGRA1 );
		CATS_LoadResourcePlttArcH(
			wk->csp, wk->crp, ah, POKE_OAM_NCLR, 0, 1, NNS_G2D_VRAM_TYPE_2DSUB, PAL_ID_POKEGRA2 );
		CATS_LoadResourceCellArcH( wk->csp, wk->crp, ah, POKE_OAM_NCER, 0, CEL_ID_POKEGRA1 );
		CATS_LoadResourceCellAnmArcH( wk->csp, wk->crp, ah, POKE_OAM_NANR, 0, ANM_ID_POKEGRA1 );

		ArchiveDataHandleClose( ah );
	}
	{
		ARCHANDLE * ah = ArchiveDataHandleOpen( ARC_DENDOU_PC_GRA, HEAPID_DENDOU_PC );

		// その他
		CATS_LoadResourceCharArcH(
			wk->csp, wk->crp, ah,
			NARC_dendou_pc_m_obj_lz_NCGR, 1, NNS_G2D_VRAM_TYPE_2DMAIN, CHR_ID_ETC );
		CATS_LoadResourceCellArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_m_obj_lz_NCER, 1, CEL_ID_ETC );
		CATS_LoadResourceCellAnmArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_m_obj_lz_NANR, 1, ANM_ID_ETC );
		CATS_LoadResourcePlttArcH(
			wk->csp, wk->crp, ah,
			NARC_dendou_pc_m_obj_NCLR, 0, 2, NNS_G2D_VRAM_TYPE_2DMAIN, PAL_ID_ETC );

		// 連れ歩き
		CATS_LoadResourceCellArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_pw_obj_32_lz_NCER, 1, CEL_ID_POKEWALK1 );
		CATS_LoadResourceCellAnmArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_pw_obj_32_lz_NANR, 1, ANM_ID_POKEWALK1 );
		CATS_LoadResourceCellArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_pw_obj_64_lz_NCER, 1, CEL_ID_POKEWALK2 );
		CATS_LoadResourceCellAnmArcH(
			wk->csp, wk->crp, ah, NARC_dendou_pc_pw_obj_64_lz_NANR, 1, ANM_ID_POKEWALK2 );
		for( i=PAL_ID_POKEWALK01; i<=PAL_ID_POKEWALK16; i++ ){
			CATS_LoadResourcePlttArcH(
				wk->csp, wk->crp, ah,
				NARC_dendou_pc_pw_obj_64_NCLR, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN, i );
		}

		ArchiveDataHandleClose( ah );
	}

	wk->cap[OBJID_POKEGRA1] = CATS_ObjectAdd_S_SubDistance(
								wk->csp, wk->crp, &ClaPrm[OBJID_POKEGRA1], SUB_ACTOR_DISTANCE );
	wk->cap[OBJID_POKEGRA2] = CATS_ObjectAdd_S_SubDistance(
								wk->csp, wk->crp, &ClaPrm[OBJID_POKEGRA2], SUB_ACTOR_DISTANCE );
	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA1], 0 );
	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA2], 0 );

	wk->cap[OBJID_CURSOR] = CATS_ObjectAdd_S( wk->csp, wk->crp, &ClaPrm[OBJID_CURSOR] );
	wk->cap[OBJID_L_ARROW] = CATS_ObjectAdd_S( wk->csp, wk->crp, &ClaPrm[OBJID_L_ARROW] );
	wk->cap[OBJID_R_ARROW] = CATS_ObjectAdd_S( wk->csp, wk->crp, &ClaPrm[OBJID_R_ARROW] );
	wk->cap[OBJID_RET_BUTTON] = CATS_ObjectAdd_S( wk->csp, wk->crp, &ClaPrm[OBJID_RET_BUTTON] );

	GF_Disp_GX_VisibleControl( GX_PLANEMASK_OBJ, VISIBLE_ON );		// MAIN DISP OBJ ON
	GF_Disp_GXS_VisibleControl( GX_PLANEMASK_OBJ, VISIBLE_ON );		// SUB DISP OBJ ON
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 * @param	id		削除するＯＢＪ番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjDel( DENDOU_PC_WORK * wk, u32 id )
{
	if( wk->cap[id] != NULL ){
		CATS_ActorPointerDelete_S( wk->cap[id] );
		wk->cap[id] = NULL;
	}
}

//--------------------------------------------------------------------------------------------
/**
 * OBJ関連全削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjExit( DENDOU_PC_WORK * wk )
{
	u32	i;

	for( i=0; i<OBJID_MAX; i++ ){
		ObjDel( wk, i );
	}

	CATS_ResourceDestructor_S( wk->csp, wk->crp );
	CATS_FreeMemory( wk->csp );
}

//--------------------------------------------------------------------------------------------
/**
 * OBJメイン
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ObjMain( DENDOU_PC_WORK * wk )
{
	u32	i;

	for( i=0; i<OBJID_MAX; i++ ){
		if( wk->cap[i] != NULL ){
			CATS_ObjectUpdateCap( wk->cap[i] );
		}
	}
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連初期化
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MsgInit( DENDOU_PC_WORK * wk )
{
	wk->mman  = MSGMAN_Create( MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_dendou_pc_dat, HEAPID_DENDOU_PC );
	wk->mmons = MSGMAN_Create( MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_monsname_dat, HEAPID_DENDOU_PC );
	wk->mwaza = MSGMAN_Create( MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_wazaname_dat, HEAPID_DENDOU_PC );
	wk->wset  = WORDSET_Create( HEAPID_DENDOU_PC );
	wk->tmpbuf1 = STRBUF_Create( TEMP_STRBUF_SIZE, HEAPID_DENDOU_PC );
	wk->tmpbuf2 = STRBUF_Create( TEMP_STRBUF_SIZE, HEAPID_DENDOU_PC );

	wk->pd_name = STRBUF_Create( POKE_STRBUF_SIZE, HEAPID_DENDOU_PC );
	wk->pd_oya  = STRBUF_Create( POKE_STRBUF_SIZE, HEAPID_DENDOU_PC );

	wk->pd.nickname = wk->pd_name;
	wk->pd.oyaname  = wk->pd_oya;
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MsgExit( DENDOU_PC_WORK * wk )
{
	STRBUF_Delete( wk->pd_oya );
	STRBUF_Delete( wk->pd_name );

	STRBUF_Delete( wk->tmpbuf2 );
	STRBUF_Delete( wk->tmpbuf1 );
	WORDSET_Delete( wk->wset );
	MSGMAN_Delete( wk->mwaza );
	MSGMAN_Delete( wk->mmons );
	MSGMAN_Delete( wk->mman );
}

//--------------------------------------------------------------------------------------------
/**
 * BMP初期化
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BmpInit( DENDOU_PC_WORK * wk )
{
	u32	i;

	FontProc_LoadFont( FONT_TOUCH, HEAPID_DENDOU_PC );

	for( i=0; i<BMPWIN_MAX; i++ ){
		GF_BGL_BmpWinAddEx( wk->bgl, &wk->win[i], &BmpWinData[i] );
	}

	//「もどる」
	GF_BGL_BmpWinDataFill( &wk->win[BMPWIN_RET], 0 );
	MSGMAN_GetString( wk->mman, dendoupc_str_ret, wk->tmpbuf1 );
	GF_STR_PrintColor(
		&wk->win[BMPWIN_RET], FONT_TOUCH,
		wk->tmpbuf1,
		(BMPWIN_RET_SX*8/2)-(FontProc_GetPrintStrWidth(FONT_TOUCH,wk->tmpbuf1,0)/2),
		0,
		MSG_NO_PUT, FCOL_BN15_TOUCH, NULL );
	GF_BGL_BmpWinCgxOn( &wk->win[BMPWIN_RET] );
	GF_BGL_BmpWinOnVReq( &wk->win[BMPWIN_RET] );
}

//--------------------------------------------------------------------------------------------
/**
 * BMP削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BmpExit( DENDOU_PC_WORK * wk )
{
	u32	i;

	for( i=0; i<BMPWIN_MAX; i++ ){
		GF_BGL_BmpWinDel( &wk->win[i] );
	}

	FontProc_UnloadFont( FONT_TOUCH );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動初期化
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorInit( DENDOU_PC_WORK * wk )
{
	wk->cmwk = CURSORMOVE_Create(
					RectHitTbl,
					KeyMoveTbl,
					&CursorMoveCallBack,
					wk,
					TRUE,
					0,
					HEAPID_DENDOU_PC );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動削除
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorExit( DENDOU_PC_WORK * wk )
{
	CURSORMOVE_Exit( wk->cmwk );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック：カーソル表示（ダミー）
 *
 * @param	work		殿堂入りＰＣ画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_On( void * work, int now_pos, int old_pos )
{
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック：カーソル非表示（ダミー）
 *
 * @param	work		殿堂入りＰＣ画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_Off( void * work, int now_pos, int old_pos )
{
}
//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック：タッチ
 *
 * @param	work		殿堂入りＰＣ画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_Touch( void * work, int now_pos, int old_pos )
{
	CursorMove( work, now_pos );
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動コールバック：カーソル移動
 *
 * @param	work		殿堂入りＰＣ画面ワーク
 * @param	now_pos		現在の位置
 * @param	old_pos		前回の位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMoveCallBack_Move( void * work, int now_pos, int old_pos )
{
	CursorMove( work, now_pos );
}

//--------------------------------------------------------------------------------------------
/**
 * フェードインセット
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void FadeInSet(void)
{
	WIPE_SYS_Start(
		WIPE_PATTERN_WMS, WIPE_TYPE_FADEIN, WIPE_TYPE_FADEIN,
		WIPE_FADE_BLACK, WIPE_DEF_DIV, WIPE_DEF_SYNC, HEAPID_DENDOU_PC );
}

//--------------------------------------------------------------------------------------------
/**
 * フェードアウトセット
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void FadeOutSet(void)
{
	WIPE_SYS_Start(
		WIPE_PATTERN_WMS, WIPE_TYPE_FADEOUT, WIPE_TYPE_FADEOUT,
		WIPE_FADE_BLACK, WIPE_DEF_DIV, WIPE_DEF_SYNC, HEAPID_DENDOU_PC );
}


//--------------------------------------------------------------------------------------------
/**
 * メイン処理
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @retval	"TRUE = 処理中"
 * @retval	"FALSE = それ以外"
 */
//--------------------------------------------------------------------------------------------
static BOOL MainFunc( DENDOU_PC_WORK * wk )
{
	switch( wk->main_seq ){
	case 0:		// メイン処理
		{
			u32	ret;

			ret = GF_TP_RectHitTrg( ArrowRectHitTbl );
			if( ret == 0 ){
				if( wk->page > 0 ){
					wk->btn_id = OBJID_L_ARROW;
					wk->next_seq = 2;
					wk->main_seq = 1;
					PageChangeInit( wk );
					Snd_SePlay( SE_DENDOUPC_SCROLL );
				}
				break;
			}else if( ret == 1 ){
				if( wk->page_max >= 1 && wk->page != (wk->page_max-1) ){
					wk->btn_id = OBJID_R_ARROW;
					wk->next_seq = 3;
					wk->main_seq = 1;
					PageChangeInit( wk );
					Snd_SePlay( SE_DENDOUPC_SCROLL );
				}
				break;
			}

			ret = CURSORMOVE_MainCont( wk->cmwk );

			switch( ret ){
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
				PokeChange( wk, ret );
				if( !( sys.trg & PAD_BUTTON_DECIDE ) && ret < wk->poke_max ){
					Snd_SePlay( SE_DENDOUPC_SELECT );
				}
				break;

			case 6:
			case CURSORMOVE_CANCEL:			// キャンセル
				Snd_SePlay( SE_DENDOUPC_CANCEL );
				wk->btn_id = OBJID_RET_BUTTON;
				wk->next_seq = 4;
				wk->main_seq++;
				break;

			case CURSORMOVE_CURSOR_ON:		// カーソル表示
				break;

			case CURSORMOVE_CURSOR_MOVE:	// 移動
				PokeChange( wk, CURSORMOVE_PosGet(wk->cmwk) );
				Snd_SePlay( SE_DENDOUPC_SELECT );
				break;

			case CURSORMOVE_NONE:			// 動作なし
				{
					u8	pos = CURSORMOVE_PosGet( wk->cmwk );
					if( sys.repeat & PAD_KEY_RIGHT ){
						if( pos == 2 || pos == 5 ){
							if( wk->page_max >= 1 && wk->page != (wk->page_max-1) ){
								wk->btn_id = OBJID_R_ARROW;
								wk->next_seq = 3;
								wk->main_seq = 1;
								PageChangeInit( wk );
								Snd_SePlay( SE_DENDOUPC_SCROLL );
							}
						}
						break;
					}
					if( sys.repeat & PAD_KEY_LEFT ){
						if( pos == 0 || pos == 3 ){
							if( wk->page > 0 ){
								wk->btn_id = OBJID_L_ARROW;
								wk->next_seq = 2;
								wk->main_seq = 1;
								PageChangeInit( wk );
								Snd_SePlay( SE_DENDOUPC_SCROLL );
							}
						}
						break;
					}
				}
				break;
			}
		}
		break;

	case 1:		// ボタンアニメ
		if( ButtonAnime( wk ) == FALSE ){
			wk->main_seq = wk->next_seq;
		}
		break;

	case 2:
		PageChange( wk, -1 );
		wk->main_seq = 0;
		break;

	case 3:
		PageChange( wk, 1 );
		wk->main_seq = 0;
		break;

	case 4:		// フェードセット
		FadeOutSet();
		Snd_SePlay( SE_DENDOUPC_LOGOUT );
		return FALSE;
	}

	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * ページ切り替え初期処理
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PageChangeInit( DENDOU_PC_WORK * wk )
{
	u32	i;

	for( i=OBJID_POKEWALK01; i<=OBJID_POKEWALK16; i++ ){
		ObjDel( wk, i );
	}
	for( i=CHR_ID_POKEWALK01; i<=CHR_ID_POKEWALK16; i++ ){
		CATS_FreeResourceChar( wk->crp, i );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * ページ切り替え
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 * @param	mv		切り替え方向
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PageChange( DENDOU_PC_WORK * wk, s8 mv )
{
	RTCDate	rtc;
	u32	chr, pal;
	u16	objID;
	u16	bmpID;
	u32	i;

	wk->page += mv;

	if( wk->page < 0 ){
		wk->page = 0;
	}else if( wk->page >= wk->page_max ){
		wk->page = wk->page_max - 1;
	}

	if( wk->page_max == 1 ){
		CATS_ObjectEnableCap( wk->cap[OBJID_L_ARROW], 0 );
		CATS_ObjectEnableCap( wk->cap[OBJID_R_ARROW], 0 );
	}else{
		if( wk->page == 0 ){
			CATS_ObjectEnableCap( wk->cap[OBJID_L_ARROW], 0 );
		}else{
			CATS_ObjectEnableCap( wk->cap[OBJID_L_ARROW], 1 );
		}
		if( wk->page == (wk->page_max-1) ){
			CATS_ObjectEnableCap( wk->cap[OBJID_R_ARROW], 0 );
		}else{
			CATS_ObjectEnableCap( wk->cap[OBJID_R_ARROW], 1 );
		}
	}

	wk->taikai_num = DendouData_GetRecordNumber( wk->sv, wk->page );
	wk->poke_max   = DendouData_GetPokemonCount( wk->sv, wk->page );

	if( wk->swap_selpoke == 0 ){
		objID = OBJID_POKEWALK01;
		chr   = CHR_ID_POKEWALK01;
		pal   = PAL_ID_POKEWALK01;
		bmpID = BMPWIN_TITLE;
	}else{
		objID = OBJID_POKEWALK11;
		chr   = CHR_ID_POKEWALK11;
		pal   = PAL_ID_POKEWALK11;
		bmpID = BMPWIN_TITLE_S;
	}

	for( i=0; i<wk->poke_max; i++ ){
		DendouData_GetPokemonData( wk->sv, wk->page, i, &wk->pd );
		SelPokeObjChange( wk, objID+i, i, chr+i, pal+i );
		CATS_ObjectAnimeFrameSetCap( wk->cap[objID+i], 0 );
		CATS_ObjectAnimeSeqSetCap( wk->cap[objID+i], 0 );
	}

//	PokeInfoOff( wk );
	PokeChange( wk, CURSORMOVE_PosGet(wk->cmwk) );

	// タイトル表示
	GF_BGL_BmpWinDataFill( &wk->win[bmpID], 0 );
	MSGMAN_GetString( wk->mman, dendoupc_str_01, wk->tmpbuf1 );
	WORDSET_RegisterNumber(
		wk->wset, 0,
		DendouData_GetRecordNumber( wk->sv, wk->page ),
		4, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	DendouData_GetDate( wk->sv, wk->page, &rtc );
	WORDSET_RegisterNumber( wk->wset, 1, rtc.year+2000, 4, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_RegisterNumber( wk->wset, 2, rtc.month, 2, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_RegisterNumber( wk->wset, 3, rtc.day, 2, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->tmpbuf2, wk->tmpbuf1 );
	GF_STR_PrintColor( &wk->win[bmpID], FONT_SYSTEM, wk->tmpbuf2, 0, 0, MSG_NO_PUT, FCOL_WN15, NULL );
	GF_BGL_BmpWinCgxOn( &wk->win[bmpID] );
	GF_BGL_BmpWinOnVReq( &wk->win[bmpID] );

	wk->swap_selpoke ^= 1;
}

//--------------------------------------------------------------------------------------------
/**
 * 上画面非表示
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeInfoOff( DENDOU_PC_WORK * wk )
{
	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA1], 0 );
	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA2], 0 );

	GF_BGL_ScrClearCodeVReq( wk->bgl, GF_BGL_FRAME0_S, 0 );
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモン表示切替
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 * @param	pos		位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeChange( DENDOU_PC_WORK * wk, u32 pos )
{
	SOFT_SPRITE_ARC  ssa;
	NNSG2dImageProxy * ipc;
	NNSG2dImagePaletteProxy * ipp;
	void * buf;
	u32	cgx;
	u32	pal;
	u32	rare;
	u32	sex;
	u16	objID;
	u16	bmpID;
	u32	i;
	CHANGES_INTO_DATA_RECT rect = { POKE_TEX_X, POKE_TEX_Y, POKE_TEX_W, POKE_TEX_H, };

	if( pos >= wk->poke_max ){
		PokeInfoOff( wk );
		return;
	}

	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA1], 0 );
	CATS_ObjectEnableCap( wk->cap[OBJID_POKEGRA2], 0 );

	if( wk->swap_pokegra == 0 ){
		objID = OBJID_POKEGRA1;
		bmpID = BMPWIN_NICKNAME;
	}else{
		objID = OBJID_POKEGRA2;
		bmpID = BMPWIN_NICKNAME_S;
	}

	DendouData_GetPokemonData( wk->sv, wk->page, pos, &wk->pd );

	sex = PokeSexGetMonsNo( wk->pd.monsno, wk->pd.personalRandom );

	// Ｙ座標補正
	{
		u8	y;
		s8	h;

		PokeEditData_HeightSet( wk->ped, &h, wk->pd.monsno );
		y = PokeHeightGet(
				wk->pd.monsno, sex, PARA_FRONT, wk->pd.formNumber, wk->pd.personalRandom );
		CATS_ObjectPosSetCap_SubSurface(
			wk->cap[objID], POKEGRA_OBJ_PX, POKEGRA_OBJ_PY+y-h, SUB_ACTOR_DISTANCE );
	}

	if( PokeRareGetPara( wk->pd.idNumber, wk->pd.personalRandom ) == 0 ){
		rare = PARA_NORMAL;
	}else{
		rare = PARA_RARE;
	}

	buf  = sys_AllocMemoryLo( HEAPID_DENDOU_PC, POKEGRA_TEX_SIZE );

	PokeGraArcDataGet(
		&ssa,
		wk->pd.monsno,
		PokeSexGetMonsNo( wk->pd.monsno, wk->pd.personalRandom ),
		PARA_FRONT,
		rare,
		wk->pd.formNumber,
		wk->pd.personalRandom );

	Ex_ChangesInto_OAM_from_PokeTex_RC(
		ssa.arc_no, ssa.index_chr, HEAPID_DENDOU_PC,
		&rect, buf, wk->pd.personalRandom, FALSE, PARA_FRONT, wk->pd.monsno );

	ipc = CLACT_ImageProxyGet( wk->cap[objID]->act );
	cgx = NNS_G2dGetImageLocation( ipc, NNS_G2D_VRAM_TYPE_2DSUB );

	ObjVramTransSub( buf, cgx, POKEGRA_TEX_SIZE );

	sys_FreeMemoryEz( buf );

	ipp = CLACT_PaletteProxyGet( wk->cap[objID]->act );
	pal = NNS_G2dGetImagePaletteLocation( ipp, NNS_G2D_VRAM_TYPE_2DSUB );

	ArcUtil_PalSet(
		ssa.arc_no, ssa.index_pal, PALTYPE_SUB_OBJ, pal, POKEGRA_PAL_SIZE, HEAPID_DENDOU_PC );

	CATS_ObjectEnableCap( wk->cap[objID], 1 );

	// BMP
	for( i=0; i<7; i++ ){
		GF_BGL_BmpWinDataFill( &wk->win[bmpID+i], 0 );
	}
	// ニックネーム
	GF_STR_PrintColor(
		&wk->win[bmpID+0], FONT_SYSTEM,
		wk->pd.nickname, 0, 0, MSG_NO_PUT, FCOL_WN15, NULL );
	// 種族名・レベル
	MSGMAN_GetString( wk->mmons, wk->pd.monsno, wk->tmpbuf1 );
	GF_STR_PrintColor(
		&wk->win[bmpID+1], FONT_SYSTEM,
		wk->tmpbuf1, 0, 0, MSG_NO_PUT, FCOL_WN15, NULL );

	if( wk->pd.monsno != MONSNO_NIDORAN_F && wk->pd.monsno != MONSNO_NIDORAN_M ){
		if( sex == PARA_MALE ){
			MSGMAN_GetString( wk->mman, dendoupc_str_osu, wk->tmpbuf2 );
			GF_STR_PrintColor(
				&wk->win[bmpID+1], FONT_SYSTEM,
				wk->tmpbuf2,
				FontProc_GetPrintStrWidth(FONT_SYSTEM,wk->tmpbuf1,0)+STR_SEX_PX,
				0,
				MSG_NO_PUT, FCOL_WN15, NULL );
		}else if( sex == PARA_FEMALE ){
			MSGMAN_GetString( wk->mman, dendoupc_str_mesu, wk->tmpbuf2 );
			GF_STR_PrintColor(
				&wk->win[bmpID+1], FONT_SYSTEM,
				wk->tmpbuf2,
				FontProc_GetPrintStrWidth(FONT_SYSTEM,wk->tmpbuf1,0)+STR_SEX_PX,
				0,
				MSG_NO_PUT, FCOL_WN15, NULL );
		}
	}
	MSGMAN_GetString( wk->mman, dendoupc_str_02, wk->tmpbuf1 );
	WORDSET_RegisterNumber( wk->wset, 0, wk->pd.level, 3, NUMBER_DISPTYPE_LEFT, NUMBER_CODETYPE_DEFAULT );
	WORDSET_ExpandStr( wk->wset, wk->tmpbuf2, wk->tmpbuf1 );
	GF_STR_PrintColor(
		&wk->win[bmpID+1], FONT_SYSTEM,
		wk->tmpbuf2, 0, 16, MSG_NO_PUT, FCOL_WN15, NULL );
	// 親名
	MSGMAN_GetString( wk->mman, dendoupc_str_03, wk->tmpbuf1 );
	GF_STR_PrintColor(
		&wk->win[bmpID+2], FONT_SYSTEM,
		wk->tmpbuf1, 0, 0, MSG_NO_PUT, FCOL_WN15, NULL );
	GF_STR_PrintColor(
		&wk->win[bmpID+2], FONT_SYSTEM,
		wk->pd.oyaname,
		FontProc_GetPrintStrWidth(FONT_SYSTEM,wk->tmpbuf1,0),
		0,
		MSG_NO_PUT, FCOL_WN15, NULL );
	// 技名
	for( i=0; i<4; i++ ){
		if( wk->pd.waza[i] == 0 ){ continue; }
		MSGMAN_GetString( wk->mwaza, wk->pd.waza[i], wk->tmpbuf1 );
		GF_STR_PrintColor(
			&wk->win[bmpID+3+i], FONT_SYSTEM,
			wk->tmpbuf1,
			(BMPWIN_WAZA_SX*8/2) - (FontProc_GetPrintStrWidth(FONT_SYSTEM,wk->tmpbuf1,0)/2),
			0,
			MSG_NO_PUT, FCOL_WN15, NULL );
	}

	for( i=0; i<7; i++ ){
		GF_BGL_BmpWinCgxOn( &wk->win[bmpID+i] );
		GF_BGL_BmpWinOnVReq( &wk->win[bmpID+i] );
	}

	wk->swap_pokegra ^= 1;
}

//--------------------------------------------------------------------------------------------
/**
 * ボタンアニメ
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 *
 * @retval	"TRUE = アニメ中"
 * @retval	"FALSE = それ以外"
 */
//--------------------------------------------------------------------------------------------
static BOOL ButtonAnime( DENDOU_PC_WORK * wk )
{
	if( wk->btn_cnt == 0 ){
		CATS_ObjectPaletteSetCap( wk->cap[wk->btn_id], 1 );
	}else if( wk->btn_cnt == 4 ){
		CATS_ObjectPaletteSetCap( wk->cap[wk->btn_id], 0 );
	}else if( wk->btn_cnt == 6 ){
		wk->btn_cnt = 0;
		return FALSE;
	}
	wk->btn_cnt++;
	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * カーソル移動
 *
 * @param	wk		殿堂入りＰＣ画面ワーク
 * @param	pos		位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void CursorMove( DENDOU_PC_WORK * wk, u32 pos )
{
	const POINTER_WORK * pwk;
	u32	anm;

	pwk = CURSORMOVE_PointerWorkGet( wk->cmwk, pos );

	CATS_ObjectPosSetCap( wk->cap[OBJID_CURSOR], pwk->px, pwk->py );

	if( pos == 6 ){
		anm = 4;
	}else{
		anm = 3;
	}
	CATS_ObjectAnimeFrameSetCap( wk->cap[OBJID_CURSOR], 0 );
	CATS_ObjectAnimeSeqSetCap( wk->cap[OBJID_CURSOR], anm );
}

//--------------------------------------------------------------------------------------------
/**
 * 連れ歩きポケモンＯＢＪ切り替え
 *
 * @param	wk			殿堂入りＰＣ画面ワーク
 * @param	id			ＯＢＪ番号
 * @param	pos			位置
 * @param	chr_res		キャラリソース
 * @param	pal_res		パレットリソース
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void SelPokeObjChange( DENDOU_PC_WORK * wk, u32 id, u32 pos, u32 chr_res, u32 pal_res )
{
	ARCHANDLE * ah;
	PAIR_POKE_INFO	info;
	TCATS_OBJECT_ADD_PARAM_S	add;
	u32	cel_res, anm_res;
	u16	arc;
	u8	cgx_sx, cgx_sy;

	NNSG2dImageProxy * ipc;
	NNSG2dImagePaletteProxy * ipp;
	void * file;
	NNSG3dResTex * tex;
	u8 * raw;
	void * buf;
	u32	cgx;
	u32	pal;
	u32	cgx_siz;
	u32	sex;
	u32	i;

	ArchiveDataLoad( &info, ARC_PAIR_POKE_INFO, PairPokeIdx_GetIdx(wk->pd.monsno) );

	ah = ArchiveDataHandleOpen( ARC_DENDOU_PC_GRA, HEAPID_DENDOU_PC );

	if( info.BigSize ){
		arc = NARC_dendou_pc_pw_obj_64_lz_NCGR;
		cel_res = CEL_ID_POKEWALK2;
		anm_res = ANM_ID_POKEWALK2;
		cgx_sx = 8;
		cgx_sy = 8;
	}else{
		arc = NARC_dendou_pc_pw_obj_32_lz_NCGR;
		cel_res = CEL_ID_POKEWALK1;
		anm_res = ANM_ID_POKEWALK1;
		cgx_sx = 4;
		cgx_sy = 4;
	}
	CATS_LoadResourceCharArcH( wk->csp, wk->crp, ah, arc, 1, NNS_G2D_VRAM_TYPE_2DMAIN, chr_res );

	ArchiveDataHandleClose( ah );

	add = SelPokeParam;

	add.id[0] = chr_res;
	add.id[1] = pal_res;
	add.id[2] = cel_res;
	add.id[3] = anm_res;

	add.x = SelPokePosTbl[pos][0];
	add.y = SelPokePosTbl[pos][1];

	wk->cap[id] = CATS_ObjectAdd_S( wk->csp, wk->crp, &add );

	ipc = CLACT_ImageProxyGet( wk->cap[id]->act );
	cgx = NNS_G2dGetImageLocation( ipc, NNS_G2D_VRAM_TYPE_2DMAIN );

	cgx_siz = 0x20 * cgx_sx * cgx_sy;

	sex = PokeSexGetMonsNo( wk->pd.monsno, wk->pd.personalRandom );
	// アーカイブインデックス取得
	arc = GetMonsArcIdx( wk->pd.monsno, wk->pd.formNumber, sex );
	// 連れ歩きポケモンのテクスチャを読み込んでくる
	file = ArchiveDataLoadMalloc( ARC_MMODEL, arc, HEAPID_DENDOU_PC );
	// テクスチャファイルを取得
	tex = NNS_G3dGetTex( file );
	// テクスチャロウデータ取得
	raw = (u8 *)tex + tex->texInfo.ofsTex;

	buf = sys_AllocMemory( HEAPID_DENDOU_PC, cgx_siz );

	// キャラデータ用のバッファにテクスチャのロウデータを1D変換して格納
	if( wk->pd.monsno == MONSNO_KURABU || wk->pd.monsno == MONSNO_KINGURAA ){
		ChangesInto_RawData_1D_from_2D( &raw[cgx_siz*6], cgx_sx, 0, 0, cgx_sx, cgx_sy, buf );
		ObjVramTrans( buf, cgx+(cgx_siz*0), cgx_siz );
		ChangesInto_RawData_1D_from_2D( &raw[cgx_siz*7], cgx_sx, 0, 0, cgx_sx, cgx_sy, buf );
		ObjVramTrans( buf, cgx+(cgx_siz*1), cgx_siz );
	}else{
		ChangesInto_RawData_1D_from_2D( &raw[cgx_siz*2], cgx_sx, 0, 0, cgx_sx, cgx_sy, buf );
		ObjVramTrans( buf, cgx+(cgx_siz*0), cgx_siz );
		ChangesInto_RawData_1D_from_2D( &raw[cgx_siz*3], cgx_sx, 0, 0, cgx_sx, cgx_sy, buf );
		ObjVramTrans( buf, cgx+(cgx_siz*1), cgx_siz );
	}

	sys_FreeMemoryEz( buf );

	ipp = CLACT_PaletteProxyGet( wk->cap[id]->act );
	pal = NNS_G2dGetImagePaletteLocation( ipp, NNS_G2D_VRAM_TYPE_2DMAIN );

	// パレットロウデータ取得
	raw = (u8 *)tex + tex->plttInfo.ofsPlttData;
	// レアかどうかでオフセット変更
	if( PokeRareGetPara( wk->pd.idNumber, wk->pd.personalRandom ) != 0 ){
		raw = &raw[POKEWALK_PAL_SIZE];
	}
	ObjPlttVramTrans( raw, pal, POKEWALK_PAL_SIZE );

	sys_FreeMemoryEz( file );
}

//--------------------------------------------------------------------------------------------
/**
 * 連れ歩きポケモンのアーカイブインデックスを返す
 *
 * @param	inMonsNo	モンスターナンバー
 * @param	inFormNo	フォルムナンバー
 * @param	inSex		性別
 *
 * @return	アーカイブインデックス
 *
 *	pokethlon/poke_clact.cよりコピー
 */
//--------------------------------------------------------------------------------------------
static int GetMonsArcIdx(const int inMonsNo, const u16 inFormNo, const int inSex)
{
	int idx;
	if ( (inMonsNo<=0) || (MONSNO_END<inMonsNo) ){
		idx = 1;
	}else{
		idx = NARC_mmodel_tsure_001_nsbtx + PairPokeIdx_GetIdx(inMonsNo);
		//モンスターナンバーだけからだと不十分なので、ここからさらに調べる（フォルムとか）
		//性別による描き違いをして、かつ複数フォルムナンバー所持ポケモンはいないので、
		//性別違いをまずキーにして分岐
		if (PairPokeIdx_GetSexDif(inMonsNo)){		//性別による描き違いがある
			if(inSex == PARA_FEMALE ){ //メスの場合
				idx += 1;	//ベースから1シフトしたところがメスのコード
			}
		}else{		//性別による描き違いがない
			//フォルムを調べる
			int form;
			if ( inFormNo > PairPokeIdx_GetFormNum(inMonsNo) ){
				form = 0;
			}else{
				form = inFormNo;
			}
			idx += form;
		}
	}

	return idx;
}